package main

import "fmt"

func main() {
	data := []string{"","one", "two", "three", "four", "five", ""}
	// 去除空字符
	fmt.Printf("%q\n", nonempty(data))
	data = nonempty(data)
	// 反转
	reverse(data[:2])
	reverse(data[2:])
	reverse(data)

	fmt.Println(data)
}

func reverse(strings []string) {
	for i, j :=0, len(strings) - 1; i < j; i, j = i+1, j-1 {
		strings[i], strings[j] = strings[j], strings[i]
	}
}

func nonempty(strings []string) []string {
	i := 0
	for _, s := range strings {
		if s != "" {
			strings[i] = s
			i++
		}
	}
	return strings[:i]
}